#include <iostream>
#include <unistd.h>
#include <csignal>
#include <cstdlib>

void handler(int signum){
	sigset_t pending;
	sigemptyset(&pending);
	while(true){
		sigpending(&pending);
		for(int i=31;i>0;i--){
			if(sigismember(&pending, i))
				std::cout<<1;
			else
				std::cout<<0;
		}
		std::cout<<std::endl;
		sleep(1);
	}
	exit(0);
}

int main()
{
	struct sigaction act, oact;
	act.sa_handler = handler;
	sigemptyset(&act.sa_mask);
	sigaddset(&act.sa_mask, 3);
	sigaddset(&act.sa_mask, 4);
	act.sa_flags = 0;

	sigaction(SIGINT, &act, &oact);

	while(true){
		std::cout<<"hello linux:"<<getpid()<<std::endl;
		sleep(1);
	}

	return 0;
}